var chinaMapPart = {
    partArray: ["东北地区", "华北地区", "华东地区", "西北地区", "西南地区", "华南地区", "华中地区"],
    provinceArray: [
			// 22个省
			'广东', '青海', '四川', '海南', '陕西', '甘肃', '云南', '湖南', '湖北', '黑龙江', '贵州', '山东',
			'江西', '河南', '河北', '山西', '安徽', '福建', '浙江', '江苏', '吉林', '辽宁',
			// 5个自治区
			'新疆', '广西', '宁夏', '内蒙古', '西藏',
			// 4个直辖市
			'北京', '天津', '上海', '重庆',
			// 2个特别行政区
			'香港', '澳门'
    ],
    //地图 文字样式
    labelStyle: {
        normal: {
            show: true,
            textStyle: {
                fontSize: 18,
                color: '#333'
            }
        },
        emphasis: {
            show: true,
            textStyle: {
                fontSize: 18,
                color: '#333'
            }
        }
    },
    //判断某个地区是否在指定的地区数组里面
    ifPartInArray: function (partName, partArray) {
        for (var i = 0; i < partArray.length; i++) {
            if (partName == partArray[i]) {
                return true;
            }
        }
        return false;
    },
    //判断某个地区是否在指定的身份数组里面
    ifProvinceInArray: function (provinceName, provinceArray) {
        for (var i = 0; i < provinceArray.length; i++) {
            if (provinceName == provinceArray[i]) {
                return true;
            }
        }
        return false;
    },
    //通过各大分区的名字来获取相对应的url地址
    getPartUrl: function (name) {
        if (name == "东北地区") {
            return "/Content/Map/geoJson/db.geo.json"
        } else if (name == "华北地区") {
            return "/Content/Map/geoJson/hb.geo.json"
        } else if (name == "华东地区") {
            return "/Content/Map/geoJson/hd.geo.json"
        } else if (name == "西北地区") {
            return "/Content/Map/geoJson/xb.geo.json"
        } else if (name == "西南地区") {
            return "/Content/Map/geoJson/xn.geo.json"
        } else if (name == "华南地区") {
            return "/Content/Map/geoJson/hn.geo.json"
        } else if (name == "华中地区") {
            return "/Content/Map/geoJson/hz.geo.json"
        } else {
            return "/Content/Map/geoJson/area.geo.json"
        }
    },
    //通过各个省份的中文名称来得到相应的url
    getProvinceUrl: function (provinceName) {
        if (provinceName == "广东") {
            return "/Content/Map/provinceJson/guanggong.json"
        } else if (provinceName == "青海") {
            return "/Content/Map/provinceJson/qinghai.json"
        } else if (provinceName == "四川") {
            return "/Content/Map/provinceJson/sichuan.json"
        } else if (provinceName == "海南") {
            return "/Content/Map/provinceJson/hainan.json"
        } else if (provinceName == "陕西") {
            return "/Content/Map/provinceJson/shanxi1.json"
        } else if (provinceName == "甘肃") {
            return "/Content/Map/provinceJson/gansu.json"
        } else if (provinceName == "云南") {
            return "/Content/Map/provinceJson/yunnan.json"
        } else if (provinceName == "湖南") {
            return "/Content/Map/provinceJson/hunan.json"
        } else if (provinceName == "湖北") {
            return "/Content/Map/provinceJson/hubei.json"
        } else if (provinceName == "黑龙江") {
            return "/Content/Map/provinceJson/heilongjiang.json"
        } else if (provinceName == "贵州") {
            return "/Content/Map/provinceJson/guizhou.json"
        } else if (provinceName == "山东") {
            return "/Content/Map/provinceJson/shangdong.json"
        } else if (provinceName == "江西") {
            return "/Content/Map/provinceJson/jiangxi.json"
        } else if (provinceName == "河南") {
            return "/Content/Map/provinceJson/henan.json"
        } else if (provinceName == "河北") {
            return "/Content/Map/provinceJson/hebei.json"
        } else if (provinceName == "山西") {
            return "/Content/Map/provinceJson/shanxi.json"
        } else if (provinceName == "安徽") {
            return "/Content/Map/provinceJson/anhui.json"
        } else if (provinceName == "福建") {
            return "/Content/Map/provinceJson/fujian.json"
        } else if (provinceName == "浙江") {
            return "/Content/Map/provinceJson/zhejiang.json"
        } else if (provinceName == "江苏") {
            return "/Content/Map/provinceJson/jiangsu.json"
        } else if (provinceName == "吉林") {
            return "/Content/Map/provinceJson/jilin.json"
        } else if (provinceName == "辽宁") {
            return "/Content/Map/provinceJson/liaoning.json"
        } else if (provinceName == "新疆") {
            return "/Content/Map/provinceJson/xinjiang.json"
        } else if (provinceName == "广西") {
            return "/Content/Map/provinceJson/guangxi.json"
        } else if (provinceName == "宁夏") {
            return "/Content/Map/provinceJson/ningxia.json"
        } else if (provinceName == "内蒙古") {
            return "/Content/Map/provinceJson/neimenggu.json"
        } else if (provinceName == "西藏") {
            return "/Content/Map/provinceJson/xizang.json"
        } else if (provinceName == "北京") {
            return "/Content/Map/provinceJson/beijing.json"
        } else if (provinceName == "重庆") {
            return "/Content/Map/provinceJson/chongqing.json"
        } else if (provinceName == "天津") {
            return "/Content/Map/provinceJson/tianjin.json"
        } else if (provinceName == "上海") {
            return "/Content/Map/provinceJson/shanghai.json"
        } else if (provinceName == "香港") {
            return "/Content/Map/provinceJson/xianggang.json"
        } else if (provinceName == "澳门") {
            return "/Content/Map/provinceJson/aomen.json"
        }
    },
    //行业分析
    createHistogram: function (area, areaType,prod) {
        var year = $("#year").val();
        $.ajaxSetup({
            async: false
        });
        var industry = [];
        var reqWt = [];
        var atext = $(".active").text();
        var url = '';
        if (atext == '需求分析') {
            url = '/GetMapData/IndustryRequst';
        }
        else if (atext == '终端分析') {
            url = '/GetMapData/GetUserRequsrIndustry';
        }
        else if (atext == '流向分析') {
            url = '/GetMapData/GetSaleIndustry';
        }
        var count = 0;
        var company;
        $.get(url, { year: year, areatype: areaType, area: area,prod:prod }, function (result) {
            var tr = '';
            $(".Prod tbody").empty();
            if (result.length < 1) {
                tr = '<tr><td colspan="3">无数据</td></tr>';
            }
            $(result).each(function (i) {

                var j = i + 1;
                var reqwt;
                if (atext == '终端分析' || atext == '流向分析') {
                    reqwt = this.Count / 10000;
                } else {
                    reqwt = this.Count;
                }
                count += reqwt;
               
             
                if (prod == undefined) {
                    if (atext == '终端分析') {
                        tr += '<tr><td>' + j + '</td><td><a style="color:blue" href="javaScript:" onclick="chinaMapPart.careateUser(\'' + area + '\',\'' + areaType + '\',\'\',\'' + this.Key + '\')">' + this.Key + '</a></td><td>' + reqwt.toFixed(1) + '</td></tr>';
                    } else {
                        tr += '<tr><td>' + j + '</td><td><a style="color:blue" href="javaScript:" onclick="chinaMapPart.createIndustryPop(\'' + area + '\',\'' + areaType + '\',\'' + this.Key + '\')">' + this.Key + '</a></td><td>' + reqwt.toFixed(1) + '</td></tr>';
                    }
                    
                } else {
                    tr += '<tr><td>' + j + '</td><td>' + this.Key + '</td><td>' + reqwt.toFixed(1) + '</td></tr>';
                }
               

            });
            $(".Prod tbody").append(tr);
        });
        $(".Prod thead").empty();     
            $(".Prod thead").append('<tr><th>序号</th><th>行业</th><th>数量(万吨)</th></tr>');
        $("#industryWt").text(count.toFixed(1));
        var title;
        if (prod == undefined) {
            title = area;
        } else {
            title = area + '-' + prod;
        }
        layer.open({
            type: 1,
            title: ['行业分析<span style="color:red;font-size: 15px;">('+title+')</span> ', 'background-color: #fff;font-size:20px;'],
            shadeClose: true,
            shade: 0.8,
            area: ['50%', '80%'],
            content: $(".Prod"),
            success: function () {//弹窗打开后回调			
            }
        });
    },
    //终端用户前十
    careateUser: function (area, areaType,prod,industry) {
        $("#area").val(area);
        $("#areaType").val(areaType);
        var year = $("#year").val();
        if(prod)
        {
            $("#prod").val(prod);
            $("#industry").val("");
        } else if (industry)
        {
            $("#industry").val(industry);
            $("#prod").val("");
        }
        $.ajaxSetup({
            async: false
        });
        var reqwt = [];
        var finuser = [];
        $.get('/GetMapData/UserRequst', { year: year, area: area, areaType: areaType,prod:prod,industry:industry }, function (result) {
            $(result).each(function () {
                finuser.push(this.FinUserName);
                var wt = this.ReqWt / 10000;
                reqwt.push(wt.toFixed(1));
            });
        });
        var title;
        if (prod) {

            title = area + '-' + prod;
        } else if (industry) {

            title = area + '-' + industry;
        } else {
            title = area;
        }
        layer.open({
            type: 1,
            title: ['终端用户<span style="color:red;font-size: 15px;">(' + title + ')</span> ', 'background-color: #fff;font-size:20px;'],
            shadeClose: true,
            shade: 0.8,
            area: ['80%', 'auto'],
            content: $(".HistogramBox"),
            success: function () {//弹窗打开后回调	          
                var myChart = echarts.init(document.getElementById('Histogram'));
                var option = {
                    title: {
                        show: false,
                        text: '终端用户',
                        subtext: '',
                        x: 'center'
                    },
                    tooltip: {
                        trigger: 'axis'
                    },
                    toolbox: {
                        show: true,
                        feature: {
                            mark: {
                                show: true
                            },
                            dataView: {
                                show: true,
                                readOnly: true
                            },
                            magicType: {
                                show: true,
                                type: ['line', 'bar']
                            },
                            restore: {
                                show: true
                            },
                            saveAsImage: {
                                show: true
                            }
                        }
                    },
                    itemStyle: {
                        normal: {
                            show: true,
                            color: '#5AB1EF',//ffa96b
                        },
                        emphasis: {
                            show: true,
                            color: '#5AB1EF',//ffa96b	                     
                        },

                    },                 
                    label: {
                        normal: {
                            show: true,
                            position: 'top'
                        }
                    },
                    //calculable: true,
                    xAxis: [{
                        show: false,
                        type: 'category',
                        data: finuser,

                    }],
                    yAxis: [{
                        type: 'value'
                    }],
                    series: [{
                        name: '(万吨)',
                        type: 'bar',
                        data: reqwt,                  
                    }]
                };
                myChart.setOption(option);
            }


        });
    },
    ///所有终端用户
    careateUserAll: function (area, areaType) {
        var year = $("#year").val();
        $.ajaxSetup({
            async: false
        });
        var prod = $("#prod").val();
        var industry = $("#industry").val();
        var count = 0;
        $.get('/GetMapData/UserRequstAll', { year: year, area: area, areaType: areaType,prod:prod,industry:industry }, function (result) {
            var tr = '';
            if (result.length < 1) {
                tr = '<tr><td colspan="3">无数据</td></tr>';
            }
            $(result).each(function (i) {
                var j = i + 1;
                count += this.ReqWt;
                tr += '<tr><td>' + j + '</td><td>' + this.FinUserName + '</td><td>' + this.ReqWt + '</td></tr>';
            });
            $("#user tbody").empty();
            $("#user tbody").append(tr);
        });
        $("#userWt").text(count.toFixed(1));
        var title;
        if (prod) {
           
            title = area + '-' + prod;
        } else if (industry) {
            
            title = area + '-' + industry;
        } else {
            title = area;
        }
        console.log('industry:' + industry);
        layer.open({
            type: 1,
            title: ['终端用户<span style="color:red;font-size: 15px;">('+title+')</span> ', 'background-color: #fff;font-size:20px;'],
            shadeClose: true,
            shade: 0.8,
            area: ['50%', '80%'],
            content: $("#user"),
            success: function () {
              $("#prod").val("");
              $("#industry").val("");
            }
        });
    },
    //钢厂分析
    createSteelFactory: function (area, areaType, prod) {
        var ismodel;
        var isprod;
        if (area) {
            ismodel = area;
            $("#steelProd").val("");
            $("#type").val("0");
        }
        if(prod)
        {
            isprod = prod;
        }
        var year = $("#year").val();
        $.ajaxSetup({
            async: false
        });
        var count = 0;
        var type = $("#type").val();
        if (area) {
            $("#area").val(area);
        } else {
            area = $("#area").val();
        }
        if (areaType) {
            $("#areaType").val(areaType);
        } else {
            areaType = $("#areaType").val();
        }
        if (prod) {
            $("#steelProd").val(prod);
        } else {
            prod = $("#steelProd").val();
        }
        $.get('/GetMapData/GetSupplySteelFactory', { year: year, area: area, areaType: areaType,prod:prod,type:type }, function (result) {
            var tr = '';
            if (result.length < 1) {
                tr = '<tr><td colspan="3">无数据</td></tr>';
            }
            $(result).each(function (i) {
                var j = i + 1;
                count += this.Count;
                if (isprod == undefined) {
                    tr += '<tr> <td>' + j + '</td><td><a style="color:blue" href="javaScript:" onclick="chinaMapPart.createIndustryPop(\'' + area + '\',\'' + areaType + '\',\'' + this.Key + '\')">' + this.Key + '</a></td><td>' + this.Count + '</td> </tr>';
                } else {
                    tr += '<tr> <td>' + j + '</td><td>' + this.Key + '</td><td>' + this.Count + '</td> </tr>';
                }
                
            });
            $("#Steel tbody").empty();
            $("#Steel tbody").append(tr);
        });
        $("#steelWt").text(count.toFixed(1));
        var title;
        if (!isprod) {
            title = area;
        } else {
            title = area + '-' + prod;
        }
        if (ismodel)
        {
            layer.open({
                type: 1,
                title: ['钢厂分析<span style="color:red;font-size: 15px;">(' + title + ')</span> ', 'background-color: #fff;font-size:20px;'],
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '80%'],
                content: $("#Steel"),
                success: function () {

                }
            });
        }
      
    },
    //品种分析
    createIndustryPop: function (area, areaType,industry) { 
        $.ajaxSetup({
            async: false
        });
        var year = $("#year").val();
        var atext = $(".active").text();
        var url = '';
        if (atext == '需求分析') {
            url = '/GetMapData/GetProdGrid';
        }
        else if (atext == '供给分析') {
            url = '/GetMapData/GetSupplyProd';
        }
        else if (atext == '终端分析') {
            url = '/GetMapData/GetUserRequstProd';
        }
        else if (atext == '流向分析') {
            url = '/GetMapData/GetSaleProd';
        }
        var count = 0;
        var company;
        $.get(url, { year: year, area: area, areaType: areaType,industry:industry }, function (result) {
            var tr = "";
            $(".IndustryPop tbody").empty();
            $(result).each(function (i) {
                var j = i + 1;
                var reqwt;
                if (atext == '终端分析' || atext == '流向分析') {
                    reqwt=this.Count / 10000
                } else {
                    reqwt = this.Count;
                }
                count += reqwt;              
                if (industry == undefined) {
                    if (atext == '供给分析') {
                        tr += '<tr> <td>' + j + '</td><td><a style="color:blue" href="javaScript:" onclick="chinaMapPart.createSteelFactory(\'' + area + '\',\'' + areaType + '\',\'' + this.Key + '\')">' + this.Key + '</a></td><td>' + reqwt.toFixed(1) + '</td> </tr>';
                    } else if (atext == '终端分析') {
                        
                        tr += '<tr> <td>' + j + '</td><td><a style="color:blue" href="javaScript:" onclick="chinaMapPart.careateUser(\'' + area + '\',\'' + areaType + '\',\'' + this.Key + '\')">' + this.Key + '</a></td><td>' + reqwt.toFixed(1) + '</td> </tr>';
                    }
                    else {
                        tr += '<tr> <td>' + j + '</td><td><a style="color:blue" href="javaScript:" onclick="chinaMapPart.createHistogram(\'' + area + '\',\'' + areaType + '\',\'' + this.Key + '\')">' + this.Key + '</a></td><td>' + reqwt.toFixed(1) + '</td> </tr>';
                    }
                } else {
                    tr += '<tr> <td>' + j + '</td><td>' + this.Key + '</td><td>' + reqwt + '</td> </tr>';
                }
                
                
            });
            if (result.length > 0) {
                $(".IndustryPop tbody").append(tr);
            } else {
                $(".IndustryPop tbody").append('<tr><td colspan="3">无数据</td></tr>');
            }

        });
        $(".IndustryPop thead").empty();
  
            $(".IndustryPop thead").append('<tr><th>序号</th><th>品种</th><th>数量(万吨)</th></tr>');
            $("#prodWt").text(count.toFixed(1));
        var title;
        if (industry == undefined) {
            title =area;
        } else {
            title = area + '-'+industry;
        }
        layer.open({
            type: 1,
            title: ['品种分析<span style="color:red;font-size: 15px;">('+title+')</span>', 'background-color: #fff;font-size:20px;'],
            shadeClose: true,
            shade: 0.8,
            area: ['50%', '80%'],
            content: $(".IndustryPop"),
            success: function () {
                // <span style="background-color: #fff;font-size:20px;margin:0 5px 0 20px">总量:</span><span style="font-size:15px;">' + count.toFixed(1) + '</span>
            }
        });
    },
    //简介弹窗
    profiles: function (area) {
        $.ajaxSetup({
            async: false
        });
        var profiles;
        var id;
        $.get('/GetMapData/GetAreaProfiles', { Area: area }, function (result) {
            if (result.Profiles == null) {
                profiles = '无简介';
            } else {
                profiles = result.Profiles;
                id = result.Id;
            }
           
        });
        layer.open({
            type: 1,
            shade: 0.3,
            title: false, //不显示标题
            area: ['50%', '80%'],
            //content也可以是某个页面上的层，如:$(".class")
            content: '<div class="profiles"><h1>' + area + '-简介</h1><p>' + profiles + '</p></div>',
            cancel: function (index) {//关闭回调
            }
        });
    },
    //销售网点
    sellNetwork: function () {
        $.get("/Content/Map/geoJson/china.json", function (chinaJson) {
            echarts.registerMap("china", chinaJson);
            var chart = echarts.init($("#main").get(0));
            var geoCoordMap = {
                "海门1": [121.15, 31.89],
                "鄂尔多斯1": [109.781327, 39.608266],
                "招远1": [120.38, 37.35],
                "舟山1": [122.207216, 29.985295],
                "齐齐哈尔1": [123.97, 47.33],
                "盐城1": [120.13, 33.38],
            };

            var convertData = function (data) {
                var res = [];
                //for (var i = 0; i < data.length; i++) {
                //    var geoCoord = geoCoordMap[data[i].name];
                //    if (geoCoord) {
                //        res.push({
                //            name: data[i].name,
                //            value: geoCoord.concat(data[i].value)
                //        });
                //    }
                //}
                $.ajaxSetup({
                    async: false
                });
                $.get('/GetMapData/GetNetworkService', function (result) {
                    $(result).each(function () {
                        res.push({
                            name: this.NetworkName,
                            value: [this.Longitude, this.Latitude]
                        });
                    });
                });
                return res;
            };
            var option = {
                title: {
                    text: '',
                    subtext: '',
                    sublink: '',
                },
                tooltip: {
                    trigger: 'item',
                    triggerOn: 'click',
                    formatter: function (params) {
                        $.ajaxSetup({
                            async: false
                        });
                        var html = '<div class="abstract"><span>简介:</span>';
                        $.get('/GetMapData/GetNetworkProfiles', { Couty: params.name }, function (result) {

                            html += '<p>' + result + '</p></div>';
                        });
                        return html;
                     

                    },
                    position: function (point, params, dom) {
                        return [point[0] + 18, point[1] - 37];
                    }
                },
                geo: {
                    map: 'china',
                    left: '10%',
                    label: {
                        normal: {
                            show: true,
                            textStyle: {
                                fontSize: 14,
                                color: '#c7ffe6'//008a4b
                            }
                        },
                        emphasis: {
                            show: true,
                            textStyle: {
                                fontSize: 14,
                                color: '#c7ffe6'//4b7bb0
                            }
                        },
                    },
                    itemStyle: {
                        normal: {
                            color: '#69e9af',//61A8F0
                            borderColor: '#ffffff                           '
                        }//FFF6FF
                    },
                    regions: [{
                        name: '北京',
                    }, {
                        name: '天津',
                    }, {
                        name: '上海',
                    }, {
                        name: '重庆',
                    }, {
                        name: '河北',
                    }, {
                        name: '河南',
                    }, {
                        name: '云南',
                    }, {
                        name: '辽宁',
                    }, {
                        name: '黑龙江',
                    }, {
                        name: '湖南',
                    }, {
                        name: '安徽',
                    }, {
                        name: '山东',
                    }, {
                        name: '新疆',
                    }, {
                        name: '江苏',
                    }, {
                        name: '浙江',
                    }, {
                        name: '江西',
                    }, {
                        name: '湖北',
                    }, {
                        name: '广西',
                    }, {
                        name: '甘肃',
                    }, {
                        name: '山西',
                    }, {
                        name: '内蒙古',
                    }, {
                        name: '陕西',
                    }, {
                        name: '吉林',
                    }, {
                        name: '福建',
                    }, {
                        name: '贵州',
                    }, {
                        name: '广东',
                    }, {
                        name: '青海',
                    }, {
                        name: '西藏',
                    }, {
                        name: '四川',
                    }, {
                        name: '宁夏',
                    }, {
                        name: '海南',
                    }, {
                        name: '台湾',
                    }, {
                        name: '香港',
                    }, {
                        name: '澳门',

                    }],

                },
                //series: [{
                //    type: 'effectScatter',
                //    coordinateSystem: 'geo', //根据经纬度来显示标注点
                //    markPoint: {
                //        symbol: 'image://../../img/icon_star.png',
                //        data: convertData(),
                //        symbolSize: 20,
                //        label: {
                //            normal: {
                //                show: false,
                //                position: [-5, 15],
                //                formatter: '{b}',
                //            },
                //            emphasis: {
                //                show: true,
                //                formatter: '{b}',
                //                position: [-5, 15],
                //            }
                //        },
                //    },

                //}]              
                series: [
			        {
			            type: 'effectScatter',
			            coordinateSystem: 'geo',//根据经纬度来显示标注点
			            data: convertData([
			                { name: "海门", value: 9 },
			                { name: "鄂尔多斯", value: 12 },
			                { name: "招远", value: 12 },
			                { name: "舟山", value: 12 },
			                { name: "齐齐哈尔", value: 14 },
			                { name: "盐城", value: 15 },
			            ]),
			            //symbol:"pin",
			            symbolSize: 10,
			            hoverAnimation: true,
			            label: {
			                normal: {
			                    show: false,
			                    formatter: '{b}',
			                    position: [18, 15],
			                  
			                },
			                emphasis: {
			                    show: true,
			                    formatter: '{b}' ,
                                position: [18, 15],
                                textStyle: { color: '#333', fontSize: 18, fontWeight: 600 }
			                }
			            },
			            showEffectOn: 'render',
			            rippleEffect: {
			                brushType: 'stroke'
			            },
			            hoverAnimation: true,
			            itemStyle: {
			                normal: {
			                    show: true,
			                    color: 'red',
			                },
			                emphasis: {
			                    borderColor: '#fff',
			                    borderWidth: 1,
			                    color: 'red',

			                }
			            }
			        }
                ]
            }
            chart.setOption(option, true);                    
            chart.on("click", function (params) {


            });
        }, "json");
    },
    //进入地图下一级
    toNextLeval: function (urlName, color) {
        if (this.ifPartInArray(urlName, this.partArray)) {
            this.loadPart(this.getPartUrl(urlName), color);
        };
        if (this.ifProvinceInArray(urlName, this.provinceArray)) {
            this.loadProvince(this.getProvinceUrl(urlName), color);
        }
    },
    provinceColor: "",
    //初始化
    init: function () {
        /* 初始化加载地图(大的中国地图)*/
        $.get("/Content/Map/geoJson/area.geo.json", function (chinaJson) {
            echarts.registerMap("china", chinaJson);
            var chart = echarts.init($("#main").get(0));
            var areaboder = {
                normal: {
                    borderWidth: 0,
                    //borderColor:'#000',
                    //borderType:'dashed',
                },
            }; //地图边框样式
            var option = {
                title: {
                    //积微物联营销地图
                    text: '客商信息云平台营销地图',
                    subtext: '',
                    sublink: ''
                },
                tooltip: {
                    show: true,
                    trigger: 'item',
                    triggerOn: 'click',//mousemove
                    hideDelay: 2,
                    enterable: true,
                    backgroundColor: ['#fff'],
                    borderColor: '#ccc',
                    borderWidth: 1,
                    formatter: function (params, ticket, callback) {
                        //ajax请求
                        /*$.get('detail?name=' + params.name, function (content) {
                            callback(ticket, content);
                        });
                        return 'Loading';*/
                        if(params.name=='台湾')
                        {
                            return;
                        }
                        $.ajaxSetup({
                            async: false
                        });
                        var year = $("#year").val();
                        var text = $(".active").text();
                        var html = '<div class="detail">';
                        provinceColor = params.color;
                        if (text == "需求分析") {
                            $.get('/GetMapData/GetAreaRequestGrid', { year: year, area: params.name, areaType: 'Area' }, function (content) {
                                html += '<div class="total">总量:<span>' + content + '万吨</span></div>';
                            });
                        }
                        else if (text == "供给分析") {
                            $.get('/GetMapData/GetSupplyGrid', { year: year, area: params.name, areaType: 'Area' }, function (content) {
                                html += '<div class="total">总量:<span>' + content + '万吨</span></div>';
                            });
                        }
                        else if (text == "终端分析") {
                            $.get('/GetMapData/GetUserRequstGrid', { year: year, area: params.name, areaType: 'Area' }, function (content) {
                                html += '<div class="total">总量:<span>' + (content/10000).toFixed(1) + '万吨</span></div>';
                            });
                        }
                        else if (text == "流向分析") {
                            $.get('/GetMapData/GetSaleGrid', { year: year, area: params.name, areaType: 'Area' }, function (content) {
                                html += '<div class="total">总量:<span>' + (content/10000).toFixed(1) + '万吨</span></div>';
                            });
                        }

                        html += '<input type="button" onclick="chinaMapPart.profiles(\'' + params.name + '\')" value="简介"/>';

                        html += '<input type="button" onclick="chinaMapPart.createIndustryPop(\'' + params.name + '\',\'Area\')" value="品种分析"/>';
                        if (text !== '供给分析') {
                            html += '<input type="button" onclick="chinaMapPart.createHistogram(\'' + params.name + '\',\'Area\')" value="行业分析"/>';
                        } else {
                            html += '<input type="button" onclick="chinaMapPart.createSteelFactory(\'' + params.name + '\',\'Area\')" value="钢厂分析"/>';
                        }
                        if (text == '终端分析') {

                            html += '<input type="button" onclick="chinaMapPart.careateUser(\'' + params.name + '\',\'Area\')" value="终端用户"/>';
                        }
                        html += "<input type='button' onclick='chinaMapPart.toNextLeval" +
                          "(\"" + params.name + "\",\"" + params.color + "\")' value='下一级'/>";
                        //html += '</div>';
                        html += '</div>';
                        
                        return html;
                    },
                    position: function (point, params, dom) {
                        var pointObj = {
                            "西北地区": [190.5, 200],
                            "西南地区": [260.5, 348],
                            "华北地区": [460.5, 160],
                            "东北地区": [617.5, 107],
                            "华中地区": [440.5, 335],
                            "华南地区": [410.5, 449],
                            "华东地区": [515.5, 365],
                        }
                        //console.log([point[0]-92, point[1]-75]);
                        return pointObj[params.name];
                        //return [point[0]-92, point[1]-75];
                    }
                },
                dataRange: {
                    show: false,
                    x: 'left',
                    y: 'bottom',
                    splitList: [{
                        start: 1,
                        end: 10,
                        color: '#c294d6'
                    }, //西北
                        {
                            start: 11,
                            end: 20,
                            color: '#ffa96b'
                        }, //西南
                        {
                            start: 21,
                            end: 30,
                            color: '#61d0e6'
                        }, //华北
                        {
                            start: 31,
                            end: 40,
                            color: '#f5c937'
                        }, //华中
                        {
                            start: 41,
                            end: 50,
                            color: '#6bd597'
                        }, //华南
                        {
                            start: 51,
                            end: 60,
                            color: '#61a8f0'
                        }, //华东
                        {
                            start: 61,
                            end: 70,
                            color: '#f78078'
                        }, //东北
                        {
                            start: 71,
                            end: 80,
                            color: '#FFE493'
                        }//台湾
                    ],
                },
                series: [{
                    type: 'map',
                    map: 'china',
                    label: chinaMapPart.labelStyle,
                    left: '10%',
                    /*nameMap:{
                    	'西南地区':'西南地区'
                    },*/
                    data: [{
                        name: "西南地区",
                        value: 11,
                        itemStyle: areaboder
                    }, {
                        name: "西北地区",
                        value: 1,
                        itemStyle: areaboder
                    }, {
                        name: "华北地区",
                        value: 21,
                        itemStyle: areaboder
                    }, {
                        name: "华中地区",
                        value: 31,
                        itemStyle: areaboder
                    }, {
                        name: "华南地区",
                        value: 41,
                        itemStyle: areaboder
                    }, {
                        name: "华东地区",
                        value: 51,
                        itemStyle: areaboder
                    }, {
                        name: "东北地区",
                        value: 61,
                        itemStyle: areaboder
                    }, {
                        name: "台湾",
                        value: 71,
                        itemStyle: areaboder
                    }]
                }],
            };
            chart.setOption(option, true);
        }, "json");
    },
    //加载分区
    loadPart: function (url, color) {
        $.get(url, function (part) {
            echarts.registerMap("part", part);
            var chart = echarts.init($("#main").get(0));
            chart.setOption({
                tooltip: {
                    show: true,
                    trigger: 'item',
                    triggerOn: 'click',
                    hideDelay: 2,
                    enterable: true,
                    backgroundColor: ['#fff'],
                    borderColor: '#ccc',
                    borderWidth: 1,
                    formatter: function (params, ticket, callback) {
                        $.ajaxSetup({
                            async: false
                        });
                        var chinaURL = "geoJson/area.geo.json";
                        var year = $("#year").val();
                        var text = $(".active").text();
                        var html = '<div class="detail">';
                        if (text == "需求分析") {
                            $.get('/GetMapData/GetAreaRequestGrid', { year: year, area: params.name, areaType: 'Province' }, function (content) {
                                html += '<div class="total">总量:<span>' + content + '万吨</span></div>';
                            });
                        }
                        else if (text == "供给分析") {
                            $.get('/GetMapData/GetSupplyGrid', { year: year, area: params.name, areaType: 'Province' }, function (content) {
                                html += '<div class="total">总量:<span>' + content + '万吨</span></div>';
                            });
                        }
                        else if (text == "终端分析") {
                            $.get('/GetMapData/GetUserRequstGrid', { year: year, area: params.name, areaType: 'Province' }, function (content) {
                                html += '<div class="total">总量:<span>' + (content/10000).toFixed(1) + '万吨</span></div>';
                            });
                        }
                        else if (text == "流向分析") {
                            $.get('/GetMapData/GetSaleGrid', { year: year, area: params.name, areaType: 'Province' }, function (content) {
                                html += '<div class="total">总量:<span>' + (content/10000).toFixed(1) + '万吨</span></div>';
                            });
                        }
                        html += '<input type="button" onclick="chinaMapPart.profiles(\'' + params.name + '\')" value="简介"/>';
                        html += '<input type="button" onclick="chinaMapPart.createIndustryPop(\'' + params.name + '\',\'Province\')" value="品种分析"/>';
                        if (text != '供给分析') {
                            html += '<input type="button" onclick="chinaMapPart.createHistogram(\'' + params.name + '\',\'Province\')" value="行业分析"/>';
                        } else {
                            html += '<input type="button" onclick="chinaMapPart.createSteelFactory(\'' + params.name + '\',\'Province\')" value="钢厂分析"/>';
                        }

                        if (text == '终端分析') {

                            html += '<input type="button" onclick="chinaMapPart.careateUser(\'' + params.name + '\',\'Province\')" value="终端用户"/>';
                        }
                        if (text == '供给分析' || text == '流向分析') {
                            html += "<input type='button' onclick='chinaMapPart.init" +
                        "(\"" + chinaURL + "\")' value='返回'/>";
                        } else {
                            html += "<input type='button' onclick='chinaMapPart.toNextLeval" +
                        "(\"" + params.name + "\",\"" + params.color + "\")' value='下一级'/>";
                        }

                        html += '</div>';
                        return html;
                    },
                    position: function (point, params, dom) {
                        return [point[0]-140, point[1]-75];
                    }
                },
                series: [{
                    type: 'map',
                    mapType: 'part',
                    label: chinaMapPart.labelStyle,
                    /*itemStyle: {
                        normal: {
                            show: true,
                            areaColor: params.color,
                        },
                    },*/
                    itemStyle: {
                        normal: {
                            borderColor: '#985812'
                        }
                    },
                    data: [{
                        name: "西藏",
                        itemStyle: {
                            normal: {
                                areaColor: '#ffe493',
                                borderColor: '#985812'
                            }
                        }

                    }, {
                        name: "四川",
                        itemStyle: {
                            normal: {
                                areaColor: '#fdb96e',
                                borderColor: '#985812'
                            }
                        }

                    }, {
                        name: "重庆",
                        itemStyle: {
                            normal: {
                                areaColor: '#ffe6bd',
                                borderColor: '#985812'
                            }
                        }

                    }, {
                        name: "贵州",
                        itemStyle: {
                            normal: {
                                areaColor: '#fcd18f',
                                borderColor: '#985812'
                            }
                        }

                    }, {
                        name: "云南",
                        itemStyle: {
                            normal: {
                                areaColor: '#fed255',
                                borderColor: '#985812'
                            }
                        }

                    }],
                }],
            });
        }, 'json');
    },
    //加载省份
    loadProvince: function (url, color) {
        $.get(url, function (province) {
            echarts.registerMap("province", province);
            var chart = echarts.init($("#main").get(0));
            chart.setOption({
                tooltip: {
                    show: true,
                    trigger: 'item',
                    triggerOn: 'click',
                    hideDelay: 2,
                    enterable: true,
                    backgroundColor: ['#fff'],
                    borderColor: '#ccc',
                    borderWidth: 1,
                    formatter: function (params, ticket, callback) {
                        $.ajaxSetup({
                            async: false
                        });
                        var chinaURL = "geoJson/area.geo.json";
                        var year = $("#year").val();
                        var text = $(".active").text();
                        var html = '<div class="detail">';
                        if (text == "需求分析") {
                            $.get('/GetMapData/GetAreaRequestGrid', { year: year, area: params.name, areaType: 'City' }, function (content) {
                                html += '<div class="total">总量:<span>' + content + '万吨</span></div>';
                            });
                        }
                        else if (text == "供给分析") {
                            return '';
                            //$.get('/GetMapData/GetSupplyGrid', { year: year, area: params.name, areaType: 'City' }, function (content) {
                            //    html += '<div class="total">总量:<span>' + content + '</span></div>';
                            //});
                        }
                        else if (text == "终端分析") {
                            $.get('/GetMapData/GetUserRequstGrid', { year: year, area: params.name, areaType: 'City' }, function (content) {
                                html += '<div class="total">总量:<span>' + (content/10000).toFixed(1) + '万吨</span></div>';
                            });
                        }
                        else if (text == "流向分析") {
                            $.get('/GetMapData/GetSaleGrid', { year: year, area: params.name, areaType: 'City' }, function (content) {
                                html += '<div class="total">总量:<span>' + (content/10000).toFixed(1) + '万吨</span></div>';
                            });
                        }
                        html += '<input type="button" onclick="chinaMapPart.profiles(\'' + params.name + '\')" value="简介"/>';

                        html += '<input type="button" onclick="chinaMapPart.createIndustryPop(\'' + params.name + '\',\'City\')" value="品种分析"/>';
                        if (text == '终端分析') {
                            html += '<input type="button" onclick="chinaMapPart.createIndustryPop(\'' + params.name + '\',\'City\')" value="行业分析"/>';
                        }
                        if (text == '终端分析') {

                            html += '<input type="button" onclick="chinaMapPart.careateUser(\'' + params.name + '\',\'City\')" value="终端用户"/>';
                        }

                        html += "<input type='button' onclick='chinaMapPart.init" +
                     "(\"" + chinaURL + "\")' value='返回'/>";
                        html += '</div>';
                        return html;
                    },
                    position: function (point, params, dom) {
                        return [point[0]-110, point[1]-75];
                    }
                },
                series: [{
                    type: 'map',
                    mapType: 'province',
                    label: chinaMapPart.labelStyle,
                    itemStyle: {
                        normal: {
                            show: true,
                            areaColor: provinceColor
                        }
                    },
                }],
            });
        }, 'json');
    }
}
chinaMapPart.init();







